package com.crois.barrier.web.statistics;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

import java.util.UUID;


@Slf4j
public class StatisticsSvcImpl implements StatisticsSvc{

    private RabbitTemplate rabbitTemplate;

    public StatisticsSvcImpl(RabbitTemplate rabbitTemplate) {
        this.rabbitTemplate = rabbitTemplate;
    }

    @Override
    public void sendStatistics(String data) {
        CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
        rabbitTemplate.convertAndSend("barrier.statistics.exchange","statistics.send", data,correlationData);
        log.info("消息ID:{},发送成功！",correlationData.getId());
    }
}
